﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "QTextCodec.h"
#include <QUrl>
#include "QMessageBox.h"


#include <QtNetwork>
#include <QtCore>
#include <QtGui>
#include"iostream"
#include "QDesktopWidget.h"
#include "QPainter"
#include "QMessageBox.h"
#include "QNetworkAccessManager.h"
#include "QNetworkReply.h"
#include "QGraphicsOpacityEffect"
#include "QTableWidget"
#include "QListWidget.h"
#include"QPanGesture"
#include "QScrollBar.h"
#include "ui_mainwindow.h"
#include "ui_login_widget.h"
#include "ui_detail.h"
#include "ui_detail2.h"
#include "ui_detail3.h"
#include "ui_set.h"
#include "ui_cj_all.h"
#include "ui_detail4cj.h"
#include "ui_login_widget.h"
#include "ui_loading.h"
#include "QVariant.h"
#include "ui_bot.h"
#include "ui_cet.h"

#include "QUrlQuery"

#include "QDesktopServices.h"
using namespace std;


#define  MAX_X 640.0
#define  MAX_Y 960.0


namespace Ui {
	class MainWindow;
}

class QNetworkReply;
class QNetworkAccessManager;

class login_widget;



typedef struct
{
	QString class_name;/*课程名*/
	QString class_pro;/*课程性质*/
	QString class_techer;/*教师*/
	QString class_posi;/*地点*/
	QString class_time;/*节数*/



}classData;


typedef struct
{
	QString cj_name;/*课程名字*/
	QString cj_pro;/*课程性质*/
	QString cj_xuefen;/*课程学分*/
	QString cj_pingshi;/*平时成绩*/
	QString cj_qimo;/*期末成绩*/
	QString cj_chenji;/*成绩*/


}chengjiData;



class PublicFunc
{
public:
	static void resetGrid(QWidget *widget);

	static float getFactory();

};



class TableWidget :public QTableWidget
{

public:
	TableWidget(QWidget*p);

	void setupUi(QMainWindow *MainWindow);
	void retranslateUi(QMainWindow *MainWindow);
	void mouseMoveEvent(QMouseEvent *e);
	void mousePressEvent(QMouseEvent *e);
	void mouseReleaseEvent(QMouseEvent *e);

private:
	bool is_move;
	int x, y;

};



class ListWidget :public QListWidget
{

public:
	ListWidget(QWidget*p);

	void mouseMoveEvent(QMouseEvent *e);
	void mousePressEvent(QMouseEvent *e);
	void mouseReleaseEvent(QMouseEvent *e);

private:
	bool is_move;
	int x, y;

};






class setCenter
{
public:
	static bool is_show_all;
	static int current_week;/*当前周*/
	static bool is_rem;

	static void save();
	static void load();
	static void saveCurrentDate();/*保存时间戳*/


};



class dataCenter
{
public:
	classData data[7][14][3];/*7天 *12节   该位置的节数*/
	chengjiData dj_data[25];/*2最大5门成绩*/

	void clear();
	void clear_cj();

};






class bot_widget :public QWidget
{

	Q_OBJECT
public:
	bot_widget(QWidget*p);


	void setTimerStart(int t = 3000);

	void setTimerStop();

	bool parse();

	QString result;/*结果*/
	void setSendEnable(bool e);

	void add_block_to_list();

	public slots:
	void slot_timer();
	void slot_close();
	void slot_doGet(QNetworkReply*reply);
	void slot_send();

public:
	Ui::bot_widget*ui;
	void FixScreen();
	QTimer *timer_out;
	QNetworkAccessManager*manger;

};




class cet_widget :public QWidget
{

	Q_OBJECT
public:
	cet_widget(QWidget*p);


	void setTimerStart(int t = 3000);

	void setTimerStop();

	QString result;/*结果*/

	public slots:
	void slot_timer();
	void slot_close();

	void slot_doGet(QNetworkReply*reply);

	void slot_send();

public:

	Ui::cet_widget*ui;
	void FixScreen();
	QTimer *timer_out;
	QNetworkAccessManager*manger;

};






class MainWindow : public QMainWindow
{
	Q_OBJECT

public:
	~MainWindow()
	{
		delete ui;

	}

	explicit MainWindow(QWidget *parent = 0);



	bool is_on_this_week(int row, int col, int i);/*课程在本周 返回true*/
	bool is_on_this_week(int row, int col, int i, int cur);


	int now_week;/*当前查看周*/

	int getMinWeek(QString time);

	int getMaxWeek(QString time);

	void saveTable();
	void loadTable();

	void syncTable(int index);
	int time;

	public slots:

	void slot_click(int, int);/*点击*/
	void slot_move(int a, int b, int c, int d);

	void slot_new();/*添加按钮*/
	void slot_set();/*设置按钮*/
	void slot_timer_1s();/*定时器*/
	void slot_curr();/*回到本本周*/
	void slot_next();/*查看下一周*/

	void slot_pre();/*查看上一周*/



public:
	Ui::MainWindow *ui;
	login_widget*login_widget_ref;
	TableWidget*tableWidget;

	const char *char_week = "\345\221\250";
	const char*char_not_curr_week = "(\351\235\236)";
	const char*char_curr_week = "(\346\234\254)";

private:

	void initTableUI();
};








class detail_widget :public QWidget
{

	Q_OBJECT
public:
	detail_widget(QWidget*p, int x, int y);

	public slots:
	void slot_close();

public:
	Ui::detail_widget*ui;
	void FixScreen();


};





class detail_widget4 :public QWidget
{

	Q_OBJECT
public:
	detail_widget4(QWidget*p, int x);

	public slots:
	void slot_close();

public:
	Ui::detail_widget4*ui;
	void FixScreen();


};





class set_widget :public QWidget
{

	Q_OBJECT
public:
	set_widget(QWidget*p);
	MainWindow*p;

	public slots:
	void slot_cj();

	void slot_close();
	void slot_about();
	void slot_vis_guanwang();


	void  slot_is_rem();
	void slot_new();
	void slot_bot();

	void slot_cet();

	void slot_cont_me();

	void slot_check_for_update();

	void slot_info();

	void slot_is_show_all();

	void slot_modify();

public:
	Ui::set_widget*ui;
	void FixScreen();


};





class detail_widget2 :public QWidget
{

	Q_OBJECT
public:
	detail_widget2(QWidget*p, int x, int y);

	public slots:
	void slot_close();

public:
	Ui::detail_widget2*ui;
	void FixScreen();


};




class cj_all_widget :public QWidget
{

	Q_OBJECT
public:
	cj_all_widget(QWidget*p, int count);

	public slots:
	void slot_close();

public:
	Ui::cj_all_widget*ui;
	void FixScreen();
	ListWidget*listWidget_ref;


};





class detail_widget3 :public QWidget
{

	Q_OBJECT
public:
	detail_widget3(QWidget*p, int x, int y);

	public slots:
	void slot_close();

public:
	Ui::detail_widget3*ui;
	void FixScreen();

};





class loading_widget :public QWidget
{
	/*非单例*/

	Q_OBJECT
public:
	loading_widget(QWidget*p);
	public slots:
	void slot_close();

public:
	Ui::loading_widget*ui;
	void FixScreen();


};







class login_widget : public QWidget
{
	Q_OBJECT

public:
	explicit login_widget(QWidget *parent = 0);


	void exec();/*外部调用显示*/


	//loading_widget*loading;
	void setShow();
	void setStart(int time = 15000);
	void setHide();

	~login_widget();

	void setLoginVisiable(bool is);

	QTimer *timer_timeout;


	private slots:
	void doManagerFinished(QNetworkReply *reply);
	void slot_getKebiao();/*post请求*/
	void slot_getChenJi();/*post请求*/

	void on_pushButton_clicked();
	void slot_verfy();
	void slot_close();/*关闭*/
	void slot_timer();
	void slot_shuom();


private:

	void do_chengji(QByteArray &data);

	Ui::login_widget *ui;

	void FixScreen();
	QUrl homepageUrl;

	QString jsessionid;
	QString viewstate;


	QUrl captchaUrl;

	QUrl url_kebiao;
	QUrl url_chenji;

	QString info;
	QString class_arry[14];

public:

	MainWindow*p;

	QNetworkAccessManager *manager;
};






#endif // MAINWINDOW_H


